import { ReactNode } from "react"

interface LinkPros {
    href: string
    children?: ReactNode
    left?: boolean
    right?: boolean
    className?: string
    style?: React.CSSProperties
    newTab?: boolean
}

export default function Link({
    href,
    children,
    left,
    right,
    className,
    style,
    newTab,
}: LinkPros) {
    return (
        <a
            className={className}
            href={href}
            {...(newTab !== false
                ? { target: "_blank", rel: "noreferre" }
                : {})}
            style={style}
        >
            {typeof children === "string" ? (
                <>
                    {left !== false && <>&nbsp;</>}
                    <>{children}</>
                    {right !== false && <>&nbsp;</>}
                </>
            ) : (
                children
            )}
        </a>
    )
}